package com.ruoyi.system.waishu;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentHashMap;

/**
 * 事件
 */
@Slf4j
public class ThirdEvent implements Callable<JSONObject> {

    AbstractRequest request;
    TableDo tableDo;
    ConcurrentHashMap<String,String> params;
    ServiceIdEnum idEnum;
    InvokeService invokeService;

    public ThirdEvent(AbstractRequest request, TableDo tableDo, ConcurrentHashMap<String, String> params, ServiceIdEnum idEnum, InvokeService invokeService) {
        this.request = request;
        this.tableDo = tableDo;
        this.params = params;
        this.idEnum = idEnum;
        this.invokeService = invokeService;
    }

    @Override
    public JSONObject call() {
        try{
            return invokeService.invoke(request,params,idEnum.getServiceId());
        }catch (Exception e){
            log.error("{}外数服务{}调用异常：",tableDo.getKeyId(),idEnum.getServiceId(),e);
        }
        return new JSONObject();
    }
}
